<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" lang="en" xml:lang="en">
<head>    
    <meta http-equiv="content-type" content="text/html;charset=utf-8" />
    <link rel="stylesheet" type="text/css" href="<?php echo View::getPath()."css/screen.css"; ?>" media="screen" />
    <link rel="stylesheet" type="text/css" href="<?php echo View::getPath()."css/jquery-ui-1.8.18.custom.css"; ?>" media="screen" />
    <script src="<?php echo View::getPath()."js/swfobject.js" ?>" type="text/javascript"></script>
    <script src="<?php echo View::getPath() ?>js/jquery-1.7.min.js" type="text/javascript"></script>
    <script src="<?php echo View::getPath() ?>js/jquery-ui-1.8.18.custom.min.js" type="text/javascript"></script>

    <title><?php echo View::getPageTitle() ?></title>
    
     <!-- Facebook Open Graph Meta Tags --> 
     <?php echo View::getFbTags(); ?>   
        
    <!-- TODO: dodać mety -->
</head>
<script type="text/javascript">

(function(d, s, id) {
  var js, fjs = d.getElementsByTagName(s)[0];
  if (d.getElementById(id)) return;
  js = d.createElement(s); js.id = id;
  js.src = "//connect.facebook.net/pl_PL/all.js#xfbml=1";
  fjs.parentNode.insertBefore(js, fjs);
}(document, 'script', 'facebook-jssdk'));  
    
function getMovieName(movieName) {
    if ($.browser.msie && $.browser.version >= 9) {
        return $('#'+movieName).get(0);
    } else
    if ($.browser.msie) {
        return window[movieName]
    }
    else {
        return document[movieName]
    }
}

function imageReady()
{
    console.log('imageready');
    $('#submit-button').show();
}

//dupa
function setData($serialData)
{
    
}
    
function imageUploaded()
{
    console.log('uploaded');
}

   
$(document).ready(function()
{
    

$('#submit-button').live('click', function(e)
{        
    sendAjaxImage();
});

function sendAjaxImage()
{
     $.ajax({
        type: "POST",
        data: $('#add_demot_form').serialize(),
        url: "index.php?controller=demot&action=save_user",       
        success: function(data){
           // data = JSON.parse(data);  
          //  getMovieName('flashDynamicContent').setFileName(2);
            getMovieName('flashDynamicContent').sendImage();
        },
        error: function(xhr, statusText, errorThrown){
            object = {
                message  : 'error',
                type     : 'Warning',
                request  : '',
                response : xhr.responseText,
                status   : statusText,
                error    : errorThrown
            }; 
            console.log("error");
        }
    });
    
    //window.location.reload();

}
    
    $('#login-link').bind('click', function(e)
    {
        e.preventDefault();
       
        this.is_show = !this.is_show;
       
        this.is_show ? $('.login-box').show() : $('.login-box').hide();
    });
});

$(document).ready(function() {

   
$('.add-to-fav').bind('click', function(e) {   
   e.preventDefault();
   var bookmarkUrl = this.href;
   var bookmarkTitle = this.title;
	 
   if ($.browser.mozilla) 
   { 
	window.sidebar.addPanel(bookmarkTitle, bookmarkUrl,"");
   } 
   else if($.browser.msie) 
   { 
	window.external.AddFavorite( bookmarkUrl, bookmarkTitle); 
   }
   else if($.browser.opera ) 
   { 
	$(this).attr("href",bookmarkUrl);
	$(this).attr("title",bookmarkTitle);
	$(this).attr("rel","sidebar");
	$(this).click();
   } 
   else 
   { 
        alert('Proszę wcisnąć CTRL + D, aby dodać stronę do zakładek.');
   }
   
});

});
   
</script>
    
<body>
<div id="fb-root"></div>
        <div class="top-menu">
            <div class="page-container">
                <div class="" style="color:#333; text-align: right; margin:-2px;">
                    
                    <?php if (UserModel::isLoggedIn()): ?>
                        <?php if(UserModel::checkPrivileges(Privileges::ADMIN)): ?>
                            <a href="<?php echo View::getRoot()?>/index.php?controller=admin" style="color:#fff;">administracja</a>
                        <?php endif; ?>
                        <a href="<?php echo View::getRoot()?>/uzytkownik/profil" style="color:#fff;">profil</a>
                    
                        <a href="<?php echo View::getRoot()?>/uzytkownik/wyloguj">wyloguj, <b> <?php echo UserModel::getLogin (); ?></b></a>
                    <?php else: ?>
                        <a href="#" id="login-link">logowanie</a> 
                        <a href="<?php echo View::getRoot()?>/uzytkownik/zarejestruj">rejestracja</a>    
                    <?php endif; ?>
                        
                    <div class="login-box" style=" display:none;">                        
                         <form action="<?php echo View::getRoot()?>/index.php?controller=user&action=login" method="POST">
                            <input type="text" size="10" name="login"/>
                            <input type="password" size="10" name="password"/>
                            <input type="submit" value="zaloguj" id="submit-button"/>
                        </form>                   
                    </div>
                </div>
            </div>
        </div>

        <div class="page-container">
            <div class="plama"></div>
            <div class="logo">
                 <img src="<?php echo View::getPath()?>images/logo-top.png" alt="zabij.pl"/>                 
            </div>
            <div class="menu-main-container dib">
				<?php $i =1; ?>
            	<div class="item dib"><a style="background-image:url('<?php  echo View::getPath().'images/menu'.$i++ .".png"; ?>');background-repeat:no-repeat; width:70px;" href="<?php echo View::getRoot()?>/index/strona-glowna"></a></div>
                <div class="item dib"><a style="background-image:url('<?php  echo View::getPath().'images/menu'.$i++ .".png"; ?>');background-repeat:no-repeat; width:110px;"  href="<?php echo View::getRoot()?>/index/kolejka"></a></div>
                <div class="item dib"><a style="background-image:url('<?php  echo View::getPath().'images/menu'.$i++ .".png"; ?>');background-repeat:no-repeat; width:70px;"  href="<?php echo View::getRoot()?>/index/losowe"></a></div>
                <div class="item dib"><a style="background-image:url('<?php  echo View::getPath().'images/menu'.$i++ .".png"; ?>');background-repeat:no-repeat; width:60px;"  href="<?php echo View::getRoot()?>/demot/dodaj"></a></div>
                <div class="item dib"><a style="background-image:url('<?php  echo View::getPath().'images/menu'.$i++ .".png"; ?>');background-repeat:no-repeat; width:40px;"  href="<?php echo View::getRoot()?>/index/popularne"></a></div>
                <div class="item dib"><a style="background-image:url('<?php  echo View::getPath().'images/menu'.$i++ .".png"; ?>');background-repeat:no-repeat; width:90px;"  href="<?php echo View::getRoot()?>/index/kategoria"></a></div>
                <div class="item dib"><a style="background-image:url('<?php  echo View::getPath().'images/menu'.$i++ .".png"; ?>');background-repeat:no-repeat; width:70px;"  href="<?php echo View::getRoot()?>/index/szukaj"></a></div>
            </div>
            
            <?php if (is_array(View::get('demots_categories'))): ?>
            <div class="category-box">
                <?php foreach (View::get('demots_categories') as $c): ?>
                <?php $filename = View::getPath().'images/'.$c['img']; 
                if (!file_exists('./template/laywer/images/'.$c['img'])||empty($c['img']))
                {
                    $filename = View::getPath().'images/'."cart-def.png";
                }
                
                ?>
                                
                <div class="category-item dib" style="background: url(<?php echo $filename ?>) no-repeat; width:129px; height:57px;">
                    <a href="<?php echo View::getRoot()?>/index/kategoria/<?php echo $c['id']?>"><?php echo $c['name']; ?></a>
                </div>
                <?php endforeach; ?>                
            </div>
            <?php endif; ?>
            
            <?php if (intval(View::get('is_search')==1)): ?>
            <div class="search-box">
                <form action="<?php echo View::getRoot()?>/index/szukaj" method="POST">
                Wpisz frazę do wyszukania:<br/>
                <input type="text" name="query"/>
                    <input type="submit" value="Szukaj" class="mysubmit"/>
                </form>
            </div>
            <?php endif; ?>
                
            <?php if (flash_message::isMessage()): ?>
            <div class="message" style="color:#fff; margin-bottom: 5px;">
                <?php echo flash_message::getMessage(); ?>
            </div>
            <?php endif; ?>
